package com.gxa.jjty.admin.controller;

import com.github.pagehelper.PageInfo;
import com.gxa.jjty.admin.service.AlarmRecordService;
import com.gxa.jjty.admin.service.ContentService;
import com.gxa.jjty.core.common.JsonResult;
import com.gxa.jjty.core.pojo.AlarmRecord;
import com.gxa.jjty.core.pojo.Content;
import io.swagger.annotations.Api;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.Date;
import java.util.List;
import java.util.Map;

/*
@RestController
@RequestMapping("/alarmRecord")
@Api(tags = "告警记录接口")
@Log4j2
public class AlarmRecordController {

    @Autowired
    ContentService contentService;

    @Autowired
    AlarmRecordService alarmRecordService;

    @PostMapping("/selectAll")
    public Map selectAll(){
        List<AlarmRecord> alarmRecords = alarmRecordService.selectAll();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(alarmRecords);
        return jsonResult.getDataMap();
    }

    @PostMapping("/selectByPage")
    public Map selectByPage(Integer page,Integer size) throws IllegalAccessException {
        PageInfo<AlarmRecord> alarmRecordPageInfo = alarmRecordService.selectByPage(page, size);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(alarmRecordPageInfo);
        return jsonResult.getDataMap();
    }

    @PostMapping("/update")

    public Map update (Long id,String state,String content){
        Content content1 = contentService.selectById(id);
        content1.setState(state);
        content1.setContent(content);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        return jsonResult.getDataMap();
    }

    @PostMapping("/selectByField")
    public Map selectByField(Date from,Date to,String name,String state) throws IllegalAccessException {
        AlarmRecord alarmRecord = new AlarmRecord();
        alarmRecord.setName(name);
        alarmRecord.setState(state);
        List<AlarmRecord> alarmRecords = alarmRecordService.selectByField(from, to, alarmRecord);
        JsonResult jsonResult = new JsonResult();
          jsonResult.setCode("1");
          jsonResult.setData(alarmRecords);
          return jsonResult.getDataMap();
    }
}
*/
